package com.cloud.dao.impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Component;

import com.cloud.core.BaseDao;
import com.cloud.dao.LableBean;
import com.cloud.dao.MyPatientBean;

/**
 * 1Cloud1
 * @author Administrator
 * @since 2015-12-9
 * @version 1.0 
 */
@Component("LableDao")
public class LableDao extends BaseDao {
	
	public List<LableBean> getLableList(LableBean bean){
		SqlSession session = super.getInstance(true);
		List<LableBean> beanList = null;
		try {
			beanList = session.selectList("lable.list", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public List<LableBean> getMyPatientLableList(MyPatientBean bean){
		SqlSession session = super.getInstance(true);
		List<LableBean> beanList = null;
		try {
			beanList = session.selectList("lable.patientlablelist", bean);
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally {
			session.close();
		}
		return beanList;
	}
	
	public String addLable(LableBean bean){
		SqlSession session = super.getInstance(true);
		session.insert("lable.insert", bean);
		session.close();
		return bean.getId();
	}
	
	public void addLablePatient(MyPatientBean bean){
		SqlSession session = super.getInstance(true);
		session.insert("lable.insertPatientlable", bean);
		session.close();
	}
	
	public void updateLable(LableBean bean){
		SqlSession session = super.getInstance(true);
		session.update("lable.update", bean);
		session.close();
	}
	
	public void deleteLable(LableBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("lable.delete", bean);
		session.close();
	}
	
	public void deletePatientLable(MyPatientBean bean){
		SqlSession session = super.getInstance(true);
		session.delete("lable.deletePatientlable", bean);
		session.close();
	}
}
